package cn.iocoder.yudao.module.infra.service.face;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.infra.controller.admin.face.vo.FaceConfigPageReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.face.FaceConfigDO;
import cn.iocoder.yudao.module.infra.dal.mysql.face.FaceConfigMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 人脸识别配置 Service 实现类
 *
 * @author 芋道源码
 */
@Service
@Validated
@Slf4j
public class FaceConfigServiceImpl implements FaceConfigService {

    @Resource
    private FaceConfigMapper faceConfigMapper;

    @Override
    public FaceConfigDO getEnabledConfig() {
        return faceConfigMapper.selectEnabledConfig();
    }

    @Override
    public Long createConfig(FaceConfigDO faceConfig) {
        faceConfigMapper.insert(faceConfig);
        return faceConfig.getId();
    }

    @Override
    public void updateConfig(FaceConfigDO faceConfig) {
        faceConfigMapper.updateById(faceConfig);
    }

    @Override
    public void deleteConfig(Long id) {
        faceConfigMapper.deleteById(id);
    }

    @Override
    public FaceConfigDO getConfig(Long id) {
        return faceConfigMapper.selectById(id);
    }

    @Override
    public PageResult<FaceConfigDO> getConfigPage(FaceConfigPageReqVO pageReqVO) {
        return faceConfigMapper.selectPage(pageReqVO);
    }

}